﻿/**
 * 表示站点的类
 */
Subwaymap.BusLines = org.gridsofts.util.Class.define({
    name: "Subwaymap.BusLines",

    /**
     * 构造函数
     */
    construct: function (container, line, stopsOnRoute) {
        if (arguments.length == 0 || typeof (arguments[0]) != "object") {
            throw new Error("Object construct parameter is empty, unable to initialize instance of Bus.");
        }

        // 处理参数
        this.container = container;
        this.line = line;

        this.layer = new Kinetic.Layer({
            id: "Buslinelayer_" + line.routeMapRDVID,
            line: line
        });
        this.stopsOnRoute = stopsOnRoute;
        this.container.add(this.layer);
        this.color = "#252e3c";
        this.repaint();
    },

    /**
     * 方法
     */
    methods: {
        repaint: function () {
            this.layer.clear();
            this.actualDrawBus();
        },
        /** 
         * 调用绘图API
         */
        actualDrawBus: function () {
            var stopsOnRoute = this.stopsOnRoute;
            var busImg;
            var line = this.line;

            // 创建 Group，将 多个 属性放入 Group 中
            var group = new Kinetic.Group({
                draggable: true,
                busLineName: "测试",
                line: line,
                type:"Bus",
                busCode: "BusGroup" + stopsOnRoute.routeMapStopID,
                container: this.container
            });

            //busImg = new Kinetic.Image({
            //    x: parseInt(this.stopsOnRoute.stopX) + 10,
            //    y: parseInt(this.stopsOnRoute.stopY) + 45,
            //    image: "../images/bus.png",
            //    width: 100,
            //    height: 100
            //});

            //group.add(busImg);

            //busCode = new Kinetic.Text({
            //    x: parseInt(this.stopsOnRoute.stopX) + 25,
            //    y: parseInt(this.stopsOnRoute.stopY) + 20,
            //    fontVariant: 'small-caps',
            //    text: stopsOnRoute.routeMapStopID,
            //    align: 'center',
            //    fontSize: "30",
            //    fontFamily: 'Arial',
            //    fill: this.color,
            //    fontStyle: "1000"
            //});

            //group.add(busCode);

            group.addEventListener("click", function () {
                // 动态设置 面板显示在屏幕中间
                $("#busPanelDetail").css({ "left": "50%", "top": "50%" });
                $("#busPanelDetail,#mask").show();
                elementDraggable("busPanelDetail");
                return false;
            });

            this.layer.add(group);
        }
    }
});